//https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49?tpId=13&tqId=23268&ru=%2Fpractice%2F54275ddae22f475981afa2244dd448c6&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D13%26type%3D13
// 双栈实现min，min栈永远插入当前的小值；

#include <iostream>
#include <vector>
#include <climits>
#include <stack>
#include <queue>

using namespace std;


//定义栈的数据结构，请在该类型中实现一个能够得到栈中所含最小元素的min函数（时间复杂度应为O（1））。
class Solution {
  public:
    void push(int value) {
        stack1.push(value);
        if (stack2.empty()) {
            stack2.push(value);
        } else {
            int temp_val = value > stack2.top() ? stack2.top() : value;
            stack2.push(temp_val);
        }
    }
    void pop() {
        if (!stack1.empty()) {
            stack1.pop();
            stack2.pop();
        } else {
            return;
            //throw new exception("empty stack");
        }
    }
    int top() {
        if (!stack1.empty()) {
            return stack1.top();
        } else {
            return INT_MIN;
            //throw new exception("empty stack");
        }
    }
    int min() {
        if (!stack2.empty()) {
            return stack2.top();
        } else {

            return INT_MIN;
            //throw new exception("empty stack");
        }
    }
    std::stack<int> stack1;
    std::stack<int> stack2;
};